﻿
''' <summary>
''' 压缩机服务类
''' </summary>
''' <remarks></remarks>
Public Class CcapCompressorItemService
    ''' <summary>
    ''' 默认构造函数
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub New()

    End Sub


    ''' <summary>
    ''' 查询隶属机组的冷凝器
    ''' </summary>
    ''' <param name="csId">机组编号</param>
    ''' <returns>冷凝器信息</returns>
    ''' <remarks>数据集表包含字段为：`Id`,`csId`,`name`</remarks>
    Public Function GetCompressor(ByVal csId As Integer)
        Dim ds As DataSet = Nothing
        Dim strSql As String = String.Empty

        strSql = "select `Id`,`csId`,`name` from tbccCompressor where `csId` =" + csId.ToString()
        Try
            ds = SqlHelper.ExecuteDataset(strSql, Nothing)
        Catch ex As Exception
            ds = Nothing
        End Try

        Return ds
    End Function
    ''' <summary>
    ''' 删除压缩机信息
    ''' </summary>
    ''' <param name="com"></param>
    ''' <param name="id"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function DelRefTypeList(ByVal com As CcapCompressorSetItem, ByVal id As Integer) As Boolean

        Dim strSql As String
        Dim tic As New TBCC.Utility.TranstrationItem

        strSql = String.Format("delete from tbccCompressor where csid='{0}' and id='{1}'", com.Id, id)
        tic.Add(strSql, Nothing)

        Return TBCC.Utility.SqlHelper.ExecuteTranstration(tic)
    End Function
    ''' <summary>
    ''' 插入压缩机
    ''' </summary>
    ''' <param name="id"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function InsertRefTypeList(ByVal id As CcapCompressorItem) As Boolean
        Dim strSql As String
        Dim tic As New TBCC.Utility.TranstrationItem


        strSql = "Insert into tbccCompressor(id,csId,name,RelId) Values(?p0,?p1,?p2,?p3)"

        Dim p1(3) As System.Data.Common.DbParameter

        p1(0) = New MySql.Data.MySqlClient.MySqlParameter()
        p1(0).ParameterName = "p0" : p1(0).Value = id.Id

        p1(1) = New MySql.Data.MySqlClient.MySqlParameter()
        p1(1).ParameterName = "p1" : p1(1).Value = id.CsId

        p1(2) = New MySql.Data.MySqlClient.MySqlParameter()
        p1(2).ParameterName = "p2" : p1(2).Value = id.CompressorName

        p1(3) = New MySql.Data.MySqlClient.MySqlParameter()
        p1(3).ParameterName = "p3" : p1(3).Value = id.RelId


        tic.Add(strSql, p1)


        Return TBCC.Utility.SqlHelper.ExecuteTranstration(tic)

    End Function
    ''' <summary>
    ''' 更新压缩机信息
    ''' </summary>
    ''' <param name="com"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function UpDataRefTypeList(ByVal com As CcapCompressorSetItem, ByVal con As CcapCompressorItem) As Boolean
        Dim strSql As String
        Dim tic As New TBCC.Utility.TranstrationItem



        strSql = String.Format("Update tbccCompressor set name='{0}'  where id='{1}'and csId='{2}' ", con.CompressorName, con.Id, com.Id)


        tic.Add(strSql, Nothing)

        Return TBCC.Utility.SqlHelper.ExecuteTranstration(tic)
    End Function

    'Public Shared Function DevTypeMaxid(ByVal com As CcapCompressorSetItem) As Integer
    '    Dim strSql As String
    '    strSql = String.Format("Select max(id) from tbccCompressor where csID<'{0}'", com.Id)

    '    Dim obj As Object
    '    obj = SqlHelper.ExecuteScalar(strSql, Nothing)

    '    If obj Is Nothing OrElse IsDBNull(obj) Then
    '        Return 0
    '    Else
    '        Return CInt(obj)
    '    End If


    'End Function
End Class
